<?php 
$Content = QContext::instance();
$base_url = $Content->requestUDI();
$search = $base_url;
$search['action'] = 'search';
$export = $base_url;
$export['action'] = 'export';
$output = $base_url;
$output['action'] = 'output';
?>
<form id="pagerForm" method="get" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>">
		<input type="hidden" name="pageNum" value="<?php echo $pagination['current'];?>" /> <!--【必须】value=1可以写死-->
		<input type="hidden" name="numPerPage" value="<?php echo $pagination['page_size'];?>" /> <!--【可选】每页显示多少条-->
		<input type="hidden" name="orderField" value="<?php echo $orderField;?>" />
		<input type="hidden" name="orderDirection" value="<?php echo $orderDirection;?>" />
</form>

<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return navTabSearch(this);" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>" method="get">
	<div class="searchBar">
		<table class="searchContent">
		<tbody>
			<tr>
				<td><label>代理：</label>
				<select name="agent_id">
				<option value="">请选择代理....</option>
				<?php foreach ($agent_list as $k=>$v):?>
				<option value="<?php echo $k;?>" <?php echo isset($param['agent_id'])?$param['agent_id'] == $k?'selected':'':''; ?>><?php echo $v;?></option>
				<?php endforeach;?>
				</select>
				<td>
			<label>落地IP：</label>
			<input type="text" name="dstchannel" value="<?php echo isset($param['dstchannel'])?$param['dstchannel']:'';?>" />
			<td>
			<label>从</label>
			<input type="text" class="date" name="start_date" value="<?php echo isset($param['start_date'])?$param['start_date']:date('Y-m-d');?>" />- 
			<input type="text" class="date" name="end_date" value="<?php echo isset($param['end_date'])?$param['end_date']:date('Y-m-d',strtotime('+1 day'));?>" />
			</td>
			
			</tr>
			<tr>
			<td>
				<label>账号：</label>
				<input type="text" name="caller_id_number" value="<?php echo isset($param['caller_id_number'])?$param['caller_id_number']:'';?>"/>
			</td><td>
				<label>被叫：</label>
				<input type="text" name="destination_number" value="<?php echo isset($param['destination_number'])?$param['destination_number']:'';?>"/>
			</td>
		</tr></tbody></table>
		
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
				<li><a class="button" target="dwzExport" title="是否导出数据" href="<?php echo url($output)?>" ><span>导出查询结果</span></a></li>
			</ul>
		</div>
		
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			
			<?php if($_SESSION['acct']['acclevel'] <= 2):?>
			代理费用:<?php echo $costagent;?>,
			<?php endif;?>
			
			用户数:<?php echo $usercount?>,用户费用:<?php echo $costuser;?>
			<li class="line">line</li>
			
		</ul>
	</div>
	<table class="table" width="1200" layoutH="158">
		<thead>
			<tr>
				<th width="3%"><input type="checkbox" group="ids[]" class="checkboxCtrl"></th>
				<th width="5%" orderField="agent_id" >代理商</th>
				<th width="10%" >帐号</th>
				<th width="10%" >被叫</th>
				<th width="10%" >开始</th>
				<th width="10%" align="center" >应答</th>
				<th width="10%" >结束</th>
				<th width="5%" >时长</th>
				<th width="5%" >中继ip</th>
				<th width="5%" >中继费</th>
				<th width="5%" >结果</th>
				<th width="10%" >代理费(元)</th>
				<th width="10%" >用户费(元)</th>
				
			</tr>
		</thead>
		<tbody>
		
			<?php foreach ($item as $k=>$v):?>
		
			<tr target="id" rel="<?php echo $v->id?>" 
			<?php
			if ($v->calltype == 1)
			{
				echo 'bgcolor="#F3F3F3"';
			}else if ($v->calltype == 2)
			{
				echo 'bgcolor="#CC00FF"';
			}
			?>
			>
				<td><input name="ids[]" value="<?php echo $v->id?>" type="checkbox"></td>
				<td><?php echo $v->agent->acctname?></td>
				<td><?php 
				echo $v->users->acctname;
				?></td>
				<td><?php echo $v->destination_number;?> </td>
				<td><?php echo $v->start_stamp;?></td>
				<td><?php echo $v->answer_stamp;?></td>
				<td><?php echo $v->end_stamp;?></td>
				<td><?php 
				echo $v->billsec;
				?></td>
				<td></td>
				<td><?php echo $_SESSION['acct']['acclevel'] == 0 ? sprintf('%f',$v->costgateway):0;?></td>
				<td>
				<?php 
					switch ($v->hangup_cause)
					{
						case 0:
							echo '接通';
							break;
						case 1:
							echo '无应答';
							break;
						case 2:
							echo '不通';
							break;
						case 3:
							echo '其他';
							break;
					}
				
				?>
				</td>
				<td><?php echo $_SESSION['acct']['acclevel'] <= 2 ? sprintf('%f',$v->costagent):0;?></td>
				<td><?php echo sprintf('%f',$v->costuser);?></td>
				
			</tr>
			<?php endforeach;?>
		</tbody>
	</table>
	<div class="panelBar">
			<div class="pages">
			<span>显示</span>
			<select name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
				<option value="20" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==20)echo 'selected=selected';?>>20</option>
				<option value="50" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==50)echo 'selected=selected';?>>50</option>
				<option value="100" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==100)echo 'selected=selected';?>>100</option>
				<option value="200" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==200)echo 'selected=selected';?>>200</option>
			</select>
				<span>共 <?php echo $pagination['record_count'];?> 条</span>
			</div>
		
		<div class="pagination" targetType="navTab" totalCount="<?php echo $pagination['record_count'];?>" numPerPage="<?php echo $pagination['page_size'];?>" pageNumShown="10" currentPage="<?php echo $pagination['current'];?>" ></div>

	</div>
</div>